<!--
  @author heguanghua
  @since 2020/04/24 18:57
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss"/>
<body>

<div class="layui-fluid"
     th:with="hasDetail=${#authPermit.checkPermit('/dept/detail.action')},
     hasList=${#authPermit.checkPermit('/dept/list.action')},
     hasOrganizeDetail=${#authPermit.checkPermit('/organize/detail.action')},
     hasDpermitOrganizeList=${#authPermit.checkPermit('/dept/dpermit/organize/tree.action')},
     hasAddEdit=${#authPermit.checkPermit('/dept/modify/addEdit.action')},
     hasEdit=${#authPermit.checkPermit('/dept/modify/edit.action')},
     indexPushRule=${#authPermit.checkPermit('/okr/index/rule/list.action')},
     hasModifyRole=${#authPermit.checkPermit('/dept/modify/modifyRole.action') && isAssignAdmin}" ,
>

    <blockquote class="layui-crumb">
        <a th:lay-href="|${SYS_MCC}/organize/tree.action|" lay-text="组织架构">组织架构管理</a>&nbsp;&nbsp;>&nbsp;
        <a th:lay-href="|${SYS_MCC}/organize/detail.action?orgId=${organize.orgId}|" th:lay-text="组织信息"
           th:text="${organize.orgName}">组织信息</a>&nbsp;&nbsp;>
        <a th:lay-href="|${SYS_MCC}/dept/tree.action?orgId=${obj.orgId}|" lay-text="部门管理">部门管理</a>&nbsp;&nbsp;>&nbsp;

        <zmn th:text="${(obj.deptId eq null) ? '新增部门' : obj.deptName}">新增或修改部门</zmn>
    </blockquote>

    <div class="layui-card">

        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <zmn th:if="${#authPermit.checkPermit('/dept/detail.action')}">
                    <li class="layui-this"><a th:lay-href="|${SYS_MCC}/dept/detail.action?deptId=${obj.deptId}|"
                                              lay-text="部门信息">部门信息</a></li>
                </zmn>
                <zmn th:if="${#authPermit.checkPermit('/okr/index/rule/list.action')}">
                    <li th:if="${obj.deptId != null && indexPushRule}"><a
                            th:lay-href="|${SYS_OKR}/okr/index/rule/list.action?orgId=${organize.orgId}&orgName=${organize.orgName}&deptId=${obj.deptId}&deptName=${obj.deptName}&permitOrganize=${hasDpermitOrganizeList}&objMasterType=0&flag=2|"
                            lay-text="推送指标">推送指标</a></li>
                </zmn>
                <zmn th:if="${#authPermit.checkPermit('/objective/list.action')}">
                    <li><a th:if="${obj.deptId != null}"
                           th:href="|${SYS_OKR}/objective/list.action?deptId=${obj.deptId}&objMasterType=0&flag=3|"
                           lay-text="目标管理">目标管理</a>
                    </li>
                </zmn>
                <zmn th:if="${#authPermit.checkPermit('/dept/dpermit/organize/tree.action')}">
                    <li th:if="${obj.deptId != null && hasDpermitOrganizeList}"><a
                            th:lay-href="|${SYS_MCC}/dept/dpermit/organize/tree.action?deptId=${obj.deptId}|"
                            lay-text="数据权限">数据权限</a></li>
                </zmn>
            </ul>
        </div>

        <div class="layui-card-body">

            <blockquote class="layui-elem-quote layui-quote-nm">
                1、数据权限：如员工未配置数据权限，则继承其部门的数据权限，部门数据权限使用以下设置；<br/>
                2、功能权限：如员工没有授权角色，则继承其部门的默认角色。
            </blockquote>

            <form method="POST" action="" class="layui-form" lay-filter="zmn-form">

                <input type="hidden" name="orgId" th:value="${obj.orgId}"/>
                <input type="hidden" name="parentId" th:value="${obj.parentId}"/>
                <input type="hidden" name="deptId" th:value="${obj.deptId}"/>
                <!--<input type="hidden" name="deptName" th:value="${obj.deptName}"/>-->
                <input type="hidden" name="status" th:value="${obj.status}"/>
                <input type="hidden" name="leaderId" th:value="${obj.leaderId}"/>
                <input type="hidden" name="managerId" th:value="${obj.managerId}"/>
                <input type="hidden" name="bsDeptId" th:value="${obj.bsDeptId}"/>

                <div class="layui-card-header layui-margin-b"><b>基本信息</b></div>

                <div class="layui-form-item layui-form-item-sm" th:if="${organize.orgId != null}">
                    <label class="layui-form-label">所属组织：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${organize.orgName}">orgName</span>
                            <span th:text="${'<' + organize.orgId + '>'}">sysId</span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-item-sm">
                    <label class="layui-form-label">上级部门：</label>
                    <div class="layui-input-inline" style="width: 300px">
                        <select id="parentId" name="parentId" lay-search="">
                            <option value="">-选择-</option>
                            <option th:value="${parent.deptId}" th:selected="${parent.deptId == obj.parentId}"
                                    th:text="${parent.deptName}" th:each="parent:${parentList}">
                            </option>
                            ~
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">不选择则创建一级部门</div>
                </div>

                <div class="layui-form-item layui-form-item-sm" th:if="${obj.deptId != null}">
                    <label class="layui-form-label">部门ID：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${obj.deptId}">ID</span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">部门名称：</label>
                    <!--<div class="layui-form-mid">-->
                    <!--    <span th:text="${obj.deptName}"></span>-->
                    <!--</div>-->
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="deptName" th:value="${obj.deptName}" placeholder="部门的名称"
                               lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input"
                               maxlength="100"/>
                    </div>
                </div>
                <div class="layui-form-item" th:if="${obj.deptId != null}">
                    <label class="layui-form-label">数据权限：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="dpermitDeptId" th:value="${layer.deptId}"
                               th:checked="${layer.deptId == obj.dpermitDeptId}" th:title="${layer.deptName}"
                               th:each="layer:${layers}">&nbsp;
                    </div>
                </div>
                <div class="layui-form-item" th:if="${obj.deptId != null}">
                    <label class="layui-form-label">默认角色：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${role.roleId == null ? '' : role.roleName}">roleName</span>
                            <span th:text="${role.roleId == null ? '' : '<' + role.roleId + '>'}">roleId</span>
                            <a href="javascript:void(0);" lay-submit="" lay-filter="zmn-form-role" lay-text="更改默认角色"
                               style="margin-left:20px;" th:if="${hasModifyRole}">[更改]</a>
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            更改后立即生效，谨慎操作
                        </div>
                    </div>
                </div>

                <div class="layui-form-item" th:if="${obj.deptId != null}">
                    <label class="layui-form-label">负责人：</label>
                    <div class="layui-form-mid">
                        <span th:text="${manager.staffId == null ? '' : manager.realName}"></span>
                    </div>
                </div>

                <div class="layui-form-item" th:if="${obj.deptId != null}">
                    <label class="layui-form-label">直属领导：</label>
                    <div class="layui-form-mid">
                        <span th:text="${leader.staffId == null ? '' : leader.realName}"></span>
                    </div>
                </div>

                <zmn th:if="${obj.deptId > 0}">
                    <div class="layui-card-header layui-margin-b"><b>其他信息</b></div>

                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">修改人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${obj.updater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.updateTime, 'yyyy-MM-dd HH:mm:ss')}">
                                修改人/时间
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">创建人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${obj.creater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.createTime, 'yyyy-MM-dd HH:mm:ss')}">
                                创建人/时间
                            </div>
                        </div>
                    </div>
                </zmn>

                <div class="layui-form-item submit">
                    <div class="layui-input-block" th:if="${obj.deptId == null?hasAddEdit:hasEdit}">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-form-submit">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>

            </form>

        </div>

    </div>

</div>
</body>
</html>

<script type="text/javascript" th:inline="javascript">

    let json = {
        deptId: [[${obj.deptId}]]
    };

    layui.extend({
        dept_detail: "dept/zmn.dept.detail",
    }).use(['index', 'dept_detail']);

</script>
